package demo1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
public class Test02 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add(1);
        c.add(2);
        c.add("nihao");
        c.add(false);
        Iterator it = c.iterator();
        while(it.hasNext())
        {
            System.out.println(it.next());
        }

        Collection c2 = new HashSet();//使用Set时，是无序且不可重复的
        c2.add(122);
        c2.add(12);
        c2.add(2);
        Iterator it1 = c2.iterator();
        while(it1.hasNext())
        {
            System.out.println(it1.next());
        }
    }
}
